#include <iostream>
#include <map>
#include <vector>

typedef std::vector<int> IntList;
typedef std::map<int, IntList> BoundMap;

void initMap(BoundMap& argmap);
void appendlist(IntList& arglist, int value);
void display(BoundMap argmap);

int main()
{
    BoundMap m_map;
    initMap(m_map);
    std::cout << "添加之前：" << std::endl;
    display(m_map);
    BoundMap::iterator it = m_map.find(1);
    IntList& list = it->second;
    appendlist(list, 45);
    std::cout << "添加之后：" << std::endl;
    display(m_map);
    return 0;
}

void initMap(BoundMap& argmap)
{
    for (int i = 1; i < 10; ++i) {
        IntList ls;
        ls.push_back(i);
        argmap[i] = ls;
    }
}

void appendlist(IntList& arglist, int value)
{
    arglist.push_back(value);
}

void display(BoundMap argmap)
{
    BoundMap::iterator it = argmap.begin();
    while (it != argmap.end()) {
        std::cout << it->first << std::endl;
        IntList list = it->second;
        IntList::iterator listit = list.begin();
        while (listit != list.end()) {
            std::cout << "        " << *listit << std::endl;
            ++listit;
        }
        ++it;
    }
}
